/*
 * Copyright 2008 Zoundry LLC, Inc.  All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 */
package org.zoundry.gaedt.ui.views;

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.zoundry.gaedt.services.applications.IZGaeApplication;
import org.zoundry.gaedt.ui.ZGaeUIImages;


/**
 * Label provider for the table in the Google Applications view.
 */
public class ZGaeApplicationsViewLabelProvider extends LabelProvider implements ITableLabelProvider
{
    /**
     * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
     */
    public String getColumnText(Object aObject, int aIndex)
    {
        IZGaeApplication app = (IZGaeApplication) aObject;
        if (aIndex == 0)
            return app.getModel().getName();
        else if (aIndex == 1)
            return app.getStatus().getDisplayText();
        else
            return "Unknown";
    }

    /**
     * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
     */
    public Image getColumnImage(Object aObject, int aIndex)
    {
        if (aIndex == 0)
            return getImage(aObject);
        else
            return null;
    }

    /**
     * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
     */
    public Image getImage(Object aObject)
    {
        return ZGaeUIImages.getImage("icons/views/applications/server.png");
    }
}
